<?
	mysql_connect("localhost","root","root");
	mysql_select_db("database");
	mysql_query("SET NAMES UTF8");
	
	if(trim($_POST["mcdr_dr_email"]) == "")
	{
		echo "Please input mcdr_dr_email !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}
	if(trim($_POST["mcdr_dr_password"]) == "")
	{
		echo "Please input cdr_password !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}
	if(strlen($mcdr_dr_password)<6 or strlen($mcdr_dr_password)>15)
	{	
		echo "Please input password and minimum 6 charactor !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	
		
	if($_POST["mcdr_dr_password"] != $_POST["mcdr_dr_re-password"])
	{
		echo "Password not Match !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();
	}
	
	if(trim($_POST["mcdr_dr_name"]) == "")
	{
		echo "Please input Nme Doctor !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_dr_sex"]) == "")
	{
		echo "Please input Nme Doctor !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_dr_add"]) == "")
	{
		echo "Please input Address !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_dr_tambon"]) == "")
	{
		echo "Please input Address !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_dr_amphur"]) == "")
	{
		echo "Please input Address !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_dr_town"]) == "")
	{
		echo "Please input Address !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_dr_post"]) == "")
	{
		echo "Please input Address !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

	if(trim($_POST["mcdr_dr_tel"]) == "")
	{
		echo "Please input Phone Numder !";
		echo "<br> Go to <a href='register.php'>Back</a>";
		exit();	
	}	

 	
	$strSQL = "SELECT * FROM  member_mcdr_dr WHERE mcdr_dr_email = '".trim($_POST['mcdr_dr_email'])."' ";
	$objQuery = mysql_query($strSQL);
	$objResult = mysql_fetch_array($objQuery);
	mysql_query("SET NAMES UTF8");
	if($objResult)
	{
			echo "Username already exists!";
			echo "<br> Go to <a href='register.php'>Back</a>";
	}
	else
	{	

		$strSQL = "INSERT INTO member_mcdr_dr (mcdr_dr_email,mcdr_dr_password,mcdr_dr_whois,mcdr_dr_name,mcdr_dr_sex,mcdr_dr_add,mcdr_dr_tambon,mcdr_dr_amphur,mcdr_dr_town,mcdr_dr_post,mcdr_dr_tel) 
		VALUES ('".$_POST["mcdr_dr_email"]."', 
		'".$_POST["mcdr_dr_password"]."','".$_POST["mcdr_dr_whois"]."','".$_POST["mcdr_dr_name"]."','".$_POST["mcdr_dr_sex"]."','".$_POST["mcdr_dr_add"]."','".$_POST["mcdr_dr_tambon"]."','".$_POST["mcdr_dr_amphur"]."','".$_POST["mcdr_dr_town"]."','".$_POST["mcdr_dr_post"]."','".$_POST["mcdr_dr_tel"]."')";

		$objQuery = mysql_query($strSQL);
		mysql_query("SET NAMES UTF8");
		
		header("location:C-Dr.php");		
	}

	mysql_close();
?>

<!--x  สมัครสมาชิก ศัลยแพทย์    x--> 	